package no.hib.tod141.hasj.daoimpl;

import java.util.ArrayList;
import java.util.List;

import no.hib.tod141.hasj.beans.DescriptionBean;
import no.hib.tod141.hasj.beans.ProductBean;

public class DAOImpl {
	private List<ProductBean> products;
	private List<DescriptionBean> descriptions;
	
	public DAOImpl() {
		this.products = generateProductBeans();
		this.descriptions = generateDescriptionBeans();
	}

	public List<ProductBean> getProducts() {
		return products;
	}

	public List<DescriptionBean> getDescriptions() {
		return descriptions;
	}
	
	public ProductBean getProductInfoForSpecificProduct(int productNumber) {
		ProductBean matchingProduct = null;
		
		for (ProductBean currentProduct : products) {
			if (currentProduct.getProductNumber() == productNumber) {
				matchingProduct = currentProduct;
			}
		}
		
		return matchingProduct;
	}
	
	public List<DescriptionBean> getDescriptionsForSpecificProduct(int productNumber) {
		List<DescriptionBean> matchingDescriptions = new ArrayList<DescriptionBean>();
		
		for(DescriptionBean currentDescriptionBean : descriptions) {
			if (currentDescriptionBean.getProductNumber() == productNumber) {
				matchingDescriptions.add(currentDescriptionBean);
			}
		}
		
		return matchingDescriptions;
	}
	
	private List<ProductBean> generateProductBeans() {
		List<ProductBean> generatedProductBeans = new ArrayList<ProductBean>();
		
		ProductBean ethernetCable = new ProductBean(1, "Cat 5 ethernet cable", 5, "ethernetcable.png");
		generatedProductBeans.add(ethernetCable);
		
		ProductBean monitor = new ProductBean(2, "25 inch monitor", 100, "monitor.png");
		generatedProductBeans.add(monitor);
		
		ProductBean mouse = new ProductBean(3, "RAT6 Cyborg mouse", 50, "mouse.png");
		generatedProductBeans.add(mouse);
		
		return generatedProductBeans;
	}
	
	private List<DescriptionBean> generateDescriptionBeans() {
		List<DescriptionBean> generatedDescriptionBeans = new ArrayList<DescriptionBean>();
		
		DescriptionBean ethernetCableDescription_No = new DescriptionBean(1, "no", "35 meter kategori 5 express ethernet kabel");
		generatedDescriptionBeans.add(ethernetCableDescription_No);
		
		DescriptionBean ethernetCableDescription_En = new DescriptionBean(1, "en", "35 meter category 5 express ethernet cable");
		generatedDescriptionBeans.add(ethernetCableDescription_En);
		
		DescriptionBean ethernetCableDescription_De = new DescriptionBean(1, "de", "35 Meter Kategorie 5 Ethernet-Kabel express");
		generatedDescriptionBeans.add(ethernetCableDescription_De);
		
		DescriptionBean monitorDescription_No = new DescriptionBean(2, "no", "25 tommers monitor from Hamsund Technologies Inc.");
		generatedDescriptionBeans.add(monitorDescription_No);
		
		DescriptionBean monitorDescription_En = new DescriptionBean(2, "en", "25 inch monitor from Hamsund Technologies Inc.");
		generatedDescriptionBeans.add(monitorDescription_En);
		
		DescriptionBean monitorDescription_De = new DescriptionBean(2, "de", "25-Zoll-Monitor von Hamsund Technologies Inc.");
		generatedDescriptionBeans.add(monitorDescription_De);
		
		DescriptionBean mouseDescription_No = new DescriptionBean(3, "no", "Rat6 datamus fra Cyborg, beste gamingmus på markedet");
		generatedDescriptionBeans.add(mouseDescription_No);
		
		DescriptionBean mouseDescription_En = new DescriptionBean(3, "en", "Rat6 computer mouse from Cyborg, best gaming mouse available");
		generatedDescriptionBeans.add(mouseDescription_En);
		
		DescriptionBean mouseDescription_De = new DescriptionBean(3, "de", "Rat6 Computer-Maus von Cyborg, beste Gaming-Maus verfügbar");
		generatedDescriptionBeans.add(mouseDescription_De);
		
		return generatedDescriptionBeans;
	}
}
